package com.codepoorfish.controller;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.codepoorfish.anno.UserLoginToken;
import com.codepoorfish.controller.utils.R;
import com.codepoorfish.domain.Point;
import com.codepoorfish.domain.Task;
import com.codepoorfish.service.PointService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@RestController
@RequestMapping("/Points")
public class PointController {
    @Autowired
    private PointService pointService;

    @UserLoginToken
    @GetMapping
    public R getTasks(@RequestParam String username) {
        List<Point> points = pointService.list(new QueryWrapper<Point>().eq("user_name", username));
        if (points == null) {
            return new R(false, "数据查找失败！");
        } else
            return new R(true, points);
    }
    
}
